package com.ruoyi.yqhs.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yqhs.domain.YqhsScjcsj;
import com.ruoyi.yqhs.service.IYqhsScjcsjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 三次监测数据Controller
 * 
 * @author yqhs
 * @date 2025-09-07
 */
@RestController
@RequestMapping("/yqhs/scjcsj")
public class YqhsScjcsjController extends BaseController
{
    @Autowired
    private IYqhsScjcsjService yqhsScjcsjService;

    /**
     * 查询三次监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:scjcsj:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqhsScjcsj yqhsScjcsj)
    {
        startPage();
        List<YqhsScjcsj> list = yqhsScjcsjService.selectYqhsScjcsjList(yqhsScjcsj);
        return getDataTable(list);
    }

    /**
     * 导出三次监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('yqhs:scjcsj:export')")
    @Log(title = "三次监测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqhsScjcsj yqhsScjcsj)
    {
        List<YqhsScjcsj> list = yqhsScjcsjService.selectYqhsScjcsjList(yqhsScjcsj);
        ExcelUtil<YqhsScjcsj> util = new ExcelUtil<YqhsScjcsj>(YqhsScjcsj.class);
        util.exportExcel(response, list, "三次监测数据数据");
    }

    /**
     * 获取三次监测数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('yqhs:scjcsj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqhsScjcsjService.selectYqhsScjcsjById(id));
    }

    /**
     * 新增三次监测数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:scjcsj:add')")
    @Log(title = "三次监测数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqhsScjcsj yqhsScjcsj)
    {
        return toAjax(yqhsScjcsjService.insertYqhsScjcsj(yqhsScjcsj));
    }

    /**
     * 修改三次监测数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:scjcsj:edit')")
    @Log(title = "三次监测数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqhsScjcsj yqhsScjcsj)
    {
        return toAjax(yqhsScjcsjService.updateYqhsScjcsj(yqhsScjcsj));
    }

    /**
     * 删除三次监测数据
     */
    @PreAuthorize("@ss.hasPermi('yqhs:scjcsj:remove')")
    @Log(title = "三次监测数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqhsScjcsjService.deleteYqhsScjcsjByIds(ids));
    }

    /**
     * 获取最新进气口压力
     * @param jyzId
     * @return
     */
    @GetMapping(value = "getLastJqkyl/{jyzId}")
    public AjaxResult getLastJqkyl(@PathVariable("jyzId") Long jyzId)
    {
        return success(yqhsScjcsjService.selectLastJqkyl(jyzId));
    }
}
